package edu.lehigh.cse.paclab.gameframework;

import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
import org.anddev.andengine.entity.modifier.PathModifier.Path;
import org.anddev.andengine.input.touch.TouchEvent;

/**
 * Demonstration of the GameFramework
 * 
 * Note: you must set your target to Android 2.2 or later
 * 
 * Note: you must also be sure that your manifest includes WAKE_LOCK and VIBRATE
 * permissions
 * 
 * @author spear
 */
public class SampleActivity extends Framework
{

	/**
	 * Every game must provide this to specify the height of the game scene
	 */
	public int getCameraHeight()
	{
		return 320;
	}

	/**
	 * Every game must provide this to specify the width of the game scene
	 */
	public int getCameraWidth()
	{
		return 460;
	}

	/**
	 * Every game must provide this to specify the game orientation
	 */
	public ScreenOrientation getCameraOrientation()
	{
		return ScreenOrientation.LANDSCAPE;
	}

	/**
	 * Every game must provide this to specify the number of levels
	 */
	public int getNumLevels()
	{
		return 34;
	}

	/**
	 * Every game must declare how many help scenes it has
	 */
	public int getHelpScenes()
	{
		return 2;
	}

	/**
	 * every game must provide this to load images and sounds when starting the
	 * game
	 */
	@Override
	public void onLoadResources()
	{
		Media.registerSound("badsound.ogg");
		Media.registerSound("goodsound.ogg");
		Media.registerMusic("gametune.ogg", true);
		Media.registerImage("greenball.png");
		Media.registerImage("blueball.png");
		Media.registerImage("redball.png");
		Media.registerImage("mustardball.png");
		Media.registerImage("purpleball.png");
		Media.registerImage("greyball.png");
		Media.registerImage("invis.png");
		Media.registerImage("red.png");
		Media.registerImage("back.png");
		Media.registerImage("mid.png");
		Media.registerImage("front.png");
		Media.registerImage("cat2.png");
		Media.registerImage("turtle.png");
		Media.registerImage("penguin.png");
		Media.registerAnimatableImage("winkie.png", 2, 1);
		Media.registerImage("cat_hat.png");
		Media.registerImage("cat_face.png");
		
		
		
		
		//Other Images
		
		//Borders
		Media.registerImage("cave_borders.png");
		
		//Moving Objects
		Media.registerImage("lantern.png");
		
		//Large Objects
		Media.registerImage("lantern_large.png");
		
		//Backgrounds
		Media.registerImage("cave_background.png");
		
		//Stationary Obstacles
		Media.registerImage("stalactite.png");
		Media.registerImage("stalagmite.png");

		//Hero Images
		Media.registerImage("failcat.png");
		
		/**
		//Other Images
		Media.registerImage("failcat.png");
		Media.registerImage("arrow_large.png");

		//Borders
		Media.registerImage("cave_borders_top.png");
		Media.registerImage("cave_borders_bottom.png");
		Media.registerImage("clouds_top.png");
		Media.registerImage("clouds_bottom.png");
		Media.registerImage("grass_top.png");
		Media.registerImage("grass_bottom.png");

		//Moving Objects 
		Media.registerImage("lantern.png");
		Media.registerImage("comet.png");
		Media.registerImage("fish.png");
		Media.registerImage("gnome.png");

		//Large Stationary Objects
		Media.registerImage("lantern_large.png");
		Media.registerImage("comet_large.png");
		Media.registerImage("fish_large.png");
		Media.registerImage("gnome_large.png");

		//Backgrounds
		Media.registerImage("cave_background.png");
		Media.registerImage("water_background.png");
		Media.registerImage("splash.png");
		Media.registerImage("space_bg.png");
		Media.registerImage("sky_bg.png");

		//Stationary Obstacles
		Media.registerImage("stalactite.png");
		Media.registerImage("stalagmite.png");
		Media.registerImage("ballon_top.png");
		Media.registerImage("ballon_bottom.png");
		Media.registerImage("seaweed_top.png");
		Media.registerImage("seaweed_bottom.png");
		Media.registerImage("hill_top.png");
		Media.registerImage("hill_bottom.png");
		Media.registerImage("space_top.png");
		Media.registerImage("space_bottom.png");

		//Hero image for various levels
		Media.registerImage("cat_hat.png");
		Media.registerImage("cat_face.png");
		Media.registerImage("cat_hang_glider.png");
		Media.registerImage("cat_plain.png");
		Media.registerImage("cat_bowl.png");
	*/




	}




	/**
	 * Every game must provide this to actually create the levels
	 */
	public void configureLevel(int whichLevel)
	{


		//////////////////////////////////////////////////////////////////////////////////////////////////////
		///I MOVED THIS SHIT TO ITS PROPER PLACE - Also made it pretty
		///////////////////////////////////////////////////////////////////////////////////////////////////////
		// demo #1: reaching an obstacle leads to victory
		if (whichLevel == 1) {
			Scene.setIds();

			Level.reset(12*460, 320, 0, 0, false, 0, 0);

			//TEST TO SEE IF WE CAN KEEP TRACK OF THE STRENGTH
			//			Controls.addStrengthMeter();
			//Obstacle.setScribbleMode("red.png");
			PopUpScene.printTimedMessage("Testing This Level", 1);
			// Obstacle.drawBoundingBox(0, 0, 10 * 460, 320, "red.png", 1, 0, 1);
			Hero h = Hero.addNoRotateHero(20, 100, 50, 50, "failcat.png", 0, 0, 0);
			h.setStrength(10);
			//h.addRabbit(40, 100, 3, 0);
			Destination.addDestination(12*460-500, 0, 40, 320, "cat2.png", 2, 0);


			//Enemy e = Enemy.addMoveableBoxEnemy(300, 200, 40, 40, "greenball.png", 1, 0, 1);
			//e.applyPath(new Path(3).to(350, 250).to(150, 250).to(350, 250), 3);
			//Enemy e2 = Enemy.addMoveableBoxEnemy(300, 200, 40, 40, "greenball.png", 1, 0, 1);
			//e2.applyPath(new Path(3).to(750, 50).to(750, 300).to(750, 50), 3);
			Level.setVictoryDestination(1);
			//h.setVelocity(1, 0);
			//h.sletTouchAndGo(1, 0);
			Controls.sceneTouchAndGo(h, 50, 0, 12*460, 320, "invis.png", 5);
			//h.setVelocity(5,0);
			//TouchEvent e = new TouchEvent();	
			//e.isActionUp();

			// h.onAreaTouched(new TouchEvent(), h.getX(), h.getY());
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("back.png", 0, 0, 0);
			Level.addBackgroundLayer("mid.png", -20, 0, 116);
			//Level.addBackgroundLayer("front.png", -40, 0, 0);
			Level.setBackgroundScrollFactor(20);
			//Enemy.addStationaryEnemy(530, 280, 30, 30, "redball.png", 1, 1, 1);
			// Enemy.addStationaryBoxEnemy(1300, 0, 50, 320, "invis.png", 1, 0, 0);
			//  Controls.addUpButton(50, 0, 3*460, 320, "invis.png", 5);
			// Controls.addDownButton(50, 270, 360, 50, "invis.png", 5);			
		}
		//////////////////////////////////////////////////////////////////////////////////////////////////////
		///I MOVED THIS SHIT TO ITS PROPER PLACE
		///////////////////////////////////////////////////////////////////////////////////////////////////////


		else if (whichLevel == 2) {
			Scene.setIds();
			Level.reset(12*460, 320, 0, 0, false, 0, 0);
			PopUpScene.printTimedMessage("Max Test", 1);
			Hero h = Hero.addNoRotateHero(20, 100, 50, 50, "failcat.png", 1, 0, 0);
			Destination.addDestination(12*460-500, 0, 40, 320, "cat2.png", 2, 0);
			Level.setVictoryDestination(1);
			Controls.sceneTouchAndGo(h, 50, 0, 12*460, 320, "invis.png", 5);
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("cave_background.png", 0, 0, 0);
			Level.addBackgroundLayer("cave_borders.png",-20, 0, 300);
			Level.setBackgroundScrollFactor(20);
			//Enemy.addStationaryEnemy(530, 280, 30, 30, "redball.png", 1, 1, 1);
		}
		// demo #3: Destinations have limits!
		else if (whichLevel == 3) {
			Scene.setIds();
			Level.reset(3 * 460, 320, 0, 0, false, 0, 0);

			PopUpScene.printTimedMessage("Designing Level", 1);
			Hero h = Hero.addNoRotateHero(20, 100, 50, 50, "failcat.png", 1, 0, 0.6f);
			Controls.sceneTouchAndGo(h, 50, 0, 3*460, 320, "invis.png", 5);               
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("cave_background.png", 0, 0, 0);
			Level.addBackgroundLayer("cave_borders.png", -20, 0, 290);
			Level.setBackgroundScrollFactor(20);

			//       0----->//////////////////////////////////////////////////////////////////////
			//
			//
			//
			//level numbers y axis
			//
			//
			//     320----->//////////////////////////////////////////////////////////////////////
			int trigId=0;
			String top  = "stalactite.png";
			String bottom  = "stalagmite.png";
			String stat = "lantern.png";
			/*
			Enemy.addStationaryEnemy(1350, 320-260, 30, 260, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1320, 320-240, 30, 240, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1290, 320-220, 30, 220, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1260, 320-200, 30, 200, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1230, 320-180, 30, 180, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1200, 320-160, 30, 160, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1170, 320-140, 30, 140, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1140, 320-120, 30, 120, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1110, 320-100, 30, 100, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1080, 320-80, 30, 80, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1050, 320-40, 30, 40, bottom , 0, 0, 0);
			Enemy.addStationaryEnemy(1020, 320-20, 30, 20, bottom , 0, 0, 0);
			 */









		}
		// demo #4: Types of enemies
		else if (whichLevel == 4) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Level.setVictoryDestination(1);
			Enemy e = Enemy.addStationaryEnemy(250, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.applyRotation(1);
			e = Enemy.addMoveableEnemy(350, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.applyPath(new Path(3).to(350, 250).to(150, 250).to(350, 250), 3);
			e = Enemy.addMoveableEnemy(350, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.setMoveByTilting();
			PopUpScene.printTimedMessage("Be sure to avoid enemies!", 1);
			Level.setWinSound("goodsound.ogg");
			Level.setLoseSound("badsound.ogg");
			Level.setMusic("gametune.ogg");
		}
		// demo #5: Chasing shapes and larger game boards. Note that the walls
		// are a lot bouncier!
		else if (whichLevel == 5) {
			Level.reset(4 * 460, 2 * 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("A nice big screen,\nand very bouncy walls", 1);
			Obstacle.drawBoundingBox(0, 0, 4 * 460, 2 * 320, "red.png", 1, 1, 1);
			Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 10, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
		}
		// demo #6: Basic Obstacles: square, circle
		else if (whichLevel == 6) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("An obstacle's appearance may\nnot match its physics", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Obstacle.addSquareObstacle(0, 0, 35, 35, "purpleball.png", null, 0, 1, 0, 1);
			Obstacle.addCircularObstacle(100, 100, 35, 35, "purpleball.png", null, 0, 1, 0, 1);
			Level.setVictoryDestination(1);
		}
		// demo #7: More interesting square and circle obstacles
		else if (whichLevel == 7) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("These obstacles have\ndifferent physics\nparameters", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Obstacle.addCircularObstacle(0, 0, 35, 35, "purpleball.png", null, 0, 0, 100, 0);
			Obstacle.addCircularObstacle(100, 100, 35, 35, "purpleball.png", null, 0, 10, 0, 100);
			Level.setVictoryDestination(1);
		}
		// demo #8: Setting dampening factors
		else if (whichLevel == 8) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Obstacles as zoom\nstrips, friction pads\nand repellers", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Obstacle o = Obstacle.addCircularObstacle(100, 100, 35, 35, "purpleball.png", null, 0, 1, 0, 1);
			o.setDamp(-1);
			o = Obstacle.addCircularObstacle(200, 100, 35, 35, "purpleball.png", null, 0, 1, 0, 1);
			o.setDamp(5);
			o = Obstacle.addSquareObstacle(300, 100, 35, 35, "purpleball.png", null, 0, 1, 0, 1);
			o.applyRotation(2);
			o.setDamp(0.2f);
			Level.setVictoryDestination(1);
		}
		// demo #9: Draggable obstacles and rotated obstacles
		else if (whichLevel == 9) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Rotating oblong obstacles\nand draggable obstacles", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Obstacle o = Obstacle.addSquareObstacle(0, 0, 35, 35, "purpleball.png", null, 0, 0, 100, 0);
			o.enableDrag();
			o = Obstacle.addSquareObstacle(120, 120, 35, 5, "purpleball.png", null, 0, 0, 0, 0);
			o.rotate(45);
			Level.setVictoryDestination(1);
		}
		// demo #10: Paths on destinations and obstacles
		else if (whichLevel == 10) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Moving obstacles\nand destinations", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination d = Destination.addMobileDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			d.applyPath(new Path(3).to(290, 60).to(290, 260).to(290, 60), 4);
			Obstacle o = Obstacle.addSquareObstacle(0, 0, 35, 35, "purpleball.png", new Path(3).to(0, 0).to(100, 100)
					.to(0, 0), 2, 0, 100, 0);
			o.enableDrag();
			Level.setVictoryDestination(1);
		}
		// demo #11: Pokable obstacles and decorations; also show ttr flipping.
		// notice in this demo that the image flips, not just the hero's
		// instance of the image.
		else if (whichLevel == 11) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage(
					"Touch the obstacle\nto select, then\ntouch a destination\nAlso, note the hero\norientation", 1);
			Level.addDecoration(0, 0, 460, 320, "greenball.png");
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.setCanGoBackwards();
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Obstacle o = Obstacle.addSquareObstacle(0, 0, 35, 35, "purpleball.png", null, 0, 0, 100, 0);
			o.enablePoke();
			Level.setVictoryDestination(1);
		}
		// demo #12: A hero who moves L/R, but falls to the floor; also show ttr
		// flipping and parallax
		else if (whichLevel == 12) {
			Level.reset(3 * 460, 320, 10, 0, true, 0, 10);
			PopUpScene.printTimedMessage("Side scroller demo", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, 0, 1);
			Hero h = Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.setCanGoBackwards();
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("back.png", 0, 0, 0);
			Level.addBackgroundLayer("mid.png", -20, 0, 116);
			Level.addBackgroundLayer("front.png", -40, 0, 0);
			Level.setBackgroundScrollFactor(20);
		}
		// demo #13: A hero who can jump
		else if (whichLevel == 13) {
			Level.reset(3 * 460, 320, 10, 0, true, 0, 10);
			PopUpScene.printTimedMessage("Press the hero to\nmake it jump", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, 0, 1);
			Hero h = Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.makeTouchJumpable();
			Hero.setJumpImpulses(0, -10);
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("back.png", 0, 0, 0);
			Level.addBackgroundLayer("mid.png", -20, 0, 116);
			Level.addBackgroundLayer("front.png", -40, 0, 0);
			Level.setBackgroundScrollFactor(20);
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
		}
		// demo #14: jumping heroes without accelerometer control; hud jump;
		// note that multijump doesn't work! Also see how rabbit can offset
		// view, but rabbits and friction don't go together well.
		// also, notice how an invisible enemy sits after the destination to
		// cause a "loss" when the destination is missed
		else if (whichLevel == 14) {
			Level.reset(3 * 460, 320, 0, 0, false, 0, 10);
			PopUpScene.printTimedMessage("Press anywhere to jump", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, 0, 0);
			Hero h = Hero.addNoRotateBoxHero(20, 250, 30, 70, "greenball.png", 1, 0, 0);
			h.setVelocity(10, 0);
			Hero.addRabbit(200, 160, 10, 0);
			Hero.setJumpImpulses(0, -10);
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("back.png", 0, 0, 0);
			Level.addBackgroundLayer("mid.png", -20, 0, 116);
			Level.addBackgroundLayer("front.png", -40, 0, 0);
			Level.setBackgroundScrollFactor(20);
			Controls.addJumpButton(0, 0, 460, 320, "invis.png");
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Enemy.addStationaryBoxEnemy(1300, 0, 5, 320, "invis.png", 0, 0, 0);
			Level.setVictoryDestination(1);
		}
		// demo #15: TouchVelocityHero is now 'touch and go'; also show how
		// rotation can really do unintuitive things, even for boxhero
		else if (whichLevel == 15) {
			Level.reset(3 * 460, 320, 0, 0, false, 0, 10);
			PopUpScene
			.printTimedMessage("Press the hero\nto start moving\nNote that the physics\nisn't quite right", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, 0, 1);
			Hero h = Hero.addBoxHero(20, 250, 30, 70, "greenball.png", 1, 0, 0.6f);
			Hero.setJumpImpulses(0, -3);
			h.setTouchAndGo(10, 0);
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
		}
		// demo #16: shooting does something, but notice that it doesn't work
		// with rotation
		else if (whichLevel == 16) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Press the hero\nto make it shoot", 1);
			// set up our bullets
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.makeTouchShoot();
			Bullet.configBullets(100, 10, 10, "greyball.png", 0, -10, 20, -5);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Level.setVictoryDestination(1);
		}
		// demo #17: hacking bullet gravity with tilt heroes; added hud shooting
		else if (whichLevel == 17) {
			Level.reset(3 * 460, 320, 10, 0, true, 0, 10);
			PopUpScene.printTimedMessage("Press anywhere\nto shoot", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, .3f, 1);
			Hero.addNoRotateHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			Controls.addShootButton(0, 0, 460, 320, "invis.png");
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
			Controls.addJumpButton(0, 0, 460, 320, "invis.png");
			Bullet.configBullets(100, 10, 10, "greyball.png", 30, 0, 40, 0);
		}
		// demo #18: kill enemies with bullet, win by killing enemies
		else if (whichLevel == 18) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Defeat all enemies\nto win", 1);
			// set up our bullets
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(40, 270, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.makeTouchShoot();
			Bullet.configBullets(3, 4, 10, "greyball.png", 0, -10, 20, -5);
			Enemy e = Enemy.addStationaryEnemy(250, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.applyRotation(1);
			for (int i = 10; i < 200; i += 50)
				Enemy.addStationaryEnemy(i, i, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			Level.setVictoryEnemyCount();
		}
		// demo #19: HUD control buttons and ttr flipping
		else if (whichLevel == 19) {
			Level.reset(3 * 460, 320, 0, 0, false, 0, 0);
			PopUpScene.printTimedMessage("Press screen borders\nto move the hero", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, 0, 1);
			Hero h = Hero.addNoRotateHero(20, 290, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.setCanGoBackwards();
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
			Level.setBackgroundColor(0, 0, 1);
			Enemy.addStationaryEnemy(30, 30, 30, 30, "redball.png", 1, 1, 1);
			Level.addBackgroundLayer("back.png", 0, 0, 0);
			Level.addBackgroundLayer("mid.png", -20, 0, 116);
			Level.addBackgroundLayer("front.png", -40, 0, 0);
			Level.setBackgroundScrollFactor(20);
			Controls.addLeftButton(0, 50, 50, 220, "invis.png", 5);
			Controls.addRightButton(410, 50, 50, 220, "invis.png", 5);
			Controls.addUpButton(50, 0, 360, 50, "invis.png", 5);
			Controls.addDownButton(50, 270, 360, 50, "invis.png", 5);
		}
		// demo #20: fixed X velocity, Y controls
		else if (whichLevel == 20) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			Obstacle.setScribbleMode("red.png");
			PopUpScene.printTimedMessage("Reach the destination\nto win this level.", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f).makeTouchShoot();
			Hero.addHero(30, 80, 40, 40, "greenball.png", 1, 0, 0.6f).headbuttOn();
			Enemy e = Enemy.addMoveableBoxEnemy(350, 250, 30, 30, "redball.png", 1, 0, 0.6f);
			e.setKillByHeadbutt();
			e.setMoveByTilting();
			Obstacle.addCircularObstacle(30, 30, 40, 40, "mustardball.png", null, .3f, 1, 0, 0.6f).enableDrag();
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);


			Obstacle.loadSVG("babycat.svg", 0, 0,0, 10, 0, 0, 1, 1, 80, 120);

			Level.setVictoryDestination(1);
		}
		//demo#21 demo #21: strength and power #1: we can kill 2 of 3 enemies;
		// also show deathtext
		else if (whichLevel == 21) {
			Level.reset(12*460, 320, 0, 0, false, 0, 0);
			//Obstacle.setScribbleMode("red.png");
			PopUpScene.printTimedMessage("Testing This Level", 1);
			// Obstacle.drawBoundingBox(0, 0, 10 * 460, 320, "red.png", 1, 0, 1);
			Hero h = Hero.addNoRotateHero(20, 100, 50, 50, "failcat.png", 1, 0, 0.6f);
			//h.setStrength(Level.prevStrength);
			// h.setStrength(2);
			Destination.addDestination(12*460-100, 200, 40, 40, "cat2.png", 2, 0);
			Enemy e = Enemy.addMoveableBoxEnemy(300, 200, 40, 40, "greenball.png", 1, 0, 1);
			e.applyPath(new Path(3).to(350, 250).to(150, 250).to(350, 250), 3);
			Enemy e2 = Enemy.addMoveableBoxEnemy(300, 200, 40, 40, "greenball.png", 1, 0, 1);
			e2.applyPath(new Path(3).to(750, 50).to(750, 300).to(750, 50), 3);
			Level.setVictoryDestination(1);
			//h.setVelocity(1, 0);
			//h.sletTouchAndGo(1, 0);
			Controls.sceneTouchAndGo(h, 50, 0, 12*460, 320, "invis.png", 5);
			//TouchEvent e = new TouchEvent();	
			//e.isActionUp();

			// h.onAreaTouched(new TouchEvent(), h.getX(), h.getY());
			Level.setBackgroundColor(0, 0, 1);
			Level.addBackgroundLayer("back.png", 0, 0, 0);
			Level.addBackgroundLayer("mid.png", -20, 0, 116);
			Level.addBackgroundLayer("front.png", -40, 0, 0);
			Level.setBackgroundScrollFactor(20);
			Enemy.addStationaryEnemy(530, 280, 30, 30, "redball.png", 1, 1, 1);

			/*
            Level.reset(460, 320, 10, 10, true, 0, 0);
            PopUpScene.printTimedMessage("Health system demo", 1);
            Controls.addStrengthMeter();
            Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
            Hero h = Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
            h.setStrength(10);
            Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
            Level.setVictoryDestination(1);
            Enemy e = Enemy.addStationaryEnemy(250, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
            e.applyRotation(1);
            e.setDamage(4);
            e.setKillText("How did you hit that?");
            e = Enemy.addMoveableEnemy(350, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
            e.applyPath(new Path(3).to(350, 250).to(150, 250).to(350, 250), 3);
            e.setDamage(4);
            e.setKillText("Stay out of my way");
            e = Enemy.addMoveableEnemy(350, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
            e.setMoveByTilting();
            e.setDamage(4);
            e.setKillText("You can't run");
			 */
		}
		// demo #22: strength and power #2: we can win by killing enemies; also
		// timer
		else if (whichLevel == 22) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("You have 10 seconds\nto defeat the enemies", 1);
			Controls.addStrengthMeter();
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(40, 70, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.setStrength(10);
			Level.setVictoryEnemyCount();
			Enemy e = Enemy.addStationaryEnemy(250, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.applyRotation(1);
			e.setDamage(4);
			e = Enemy.addMoveableEnemy(350, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.setMoveByTilting();
			e.setDamage(4);
			Controls.addCountdown(10);
		}
		// demo #23: zoom buttons and stopwatch
		else if (whichLevel == 23) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Stopwatch demo\nAlso, press red squares\nto zoom", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(290, 10, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
			Controls.addZoomInButton(0, 0, 20, 20, "red.png", 4);
			Controls.addZoomOutButton(440, 0, 20, 20, "red.png", 0.25f);
			Controls.addStopwatch();
			Enemy e = Enemy.addStationaryEnemy(250, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.applyRotation(1);
			e.setDamage(4);
		}
		// demo #24: strength boost from goodies
		else if (whichLevel == 24) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Collect blue balls\nto increse strength", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			Enemy e = Enemy.addStationaryEnemy(250, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
			e.applyRotation(1);
			e.setDamage(4);
			e.setSound("badsound.ogg");
			//Goodie g = Goodie.addStationaryGoodie(0, 300, 10, 10, "blueball.png");
			//g.setStrengthBoost(4);
			//g.setSound("goodsound.ogg");
			Destination d = Destination.addDestination(290, 10, 10, 10, "mustardball.png", 2, 0);
			d.setSound("goodsound.ogg");
			Level.setVictoryDestination(1);
			Controls.addStrengthMeter();
		}
		// demo #25: activate destination on goodie count, hud goodiecount (with
		// max)
		else if (whichLevel == 25) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Collect blue balls\nto activate destination", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			//Goodie.addStationaryGoodie(0, 300, 10, 10, "blueball.png");
			//Goodie.addStationaryGoodie(0, 150, 10, 10, "blueball.png");
			Destination.addDestination(290, 10, 10, 10, "mustardball.png", 2, 2);
			Level.setVictoryDestination(1);
			Controls.addGoodieCount(2);
		}
		// demo #26: Invincibility from goodies, moving goodies, hud goodiecount
		// (no max)
		else if (whichLevel == 26) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("The blue ball will\nmake you invincible\nfor 15 seconds", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			for (int i = 0; i < 5; ++i) {
				Enemy e = Enemy.addStationaryEnemy(50 * i + 10, 250, 20, 20, "redball.png", 1.0f, 0.3f, 0.6f);
				e.applyRotation(1);
				e.setDamage(4);
			}
			Goodie g = Goodie.addMoveableGoodie(300, 300, 10, 10, "blueball.png");
			g.setInvincibilityDuration(15);
			g.applyPath(new Path(3).to(300, 300).to(100, 100).to(300, 300), 5);
			g.applyRotation(0.25f);
			Destination.addDestination(290, 10, 10, 10, "mustardball.png", 1, 0);
			Level.setVictoryDestination(1);
			Controls.addGoodieCount(0);
		}
		// demo #27: headbutting; rotation is a bit funny here. we probably want
		// box types?
		else if (whichLevel == 27) {
			Level.reset(3 * 460, 320, 0, 0, false, 0, 10);
			PopUpScene.printTimedMessage("Press the screen\nto headbutt", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, .3f, 0);
			Hero h = Hero.addNoRotateBoxHero(20, 250, 30, 70, "greenball.png", 1, 0, 0);
			h.setVelocity(5, 0);
			Controls.addHeadbuttButton(0, 0, 460, 320, "invis.png");
			Enemy e = Enemy.addStationaryEnemy(1100, 270, 50, 50, "redball.png", 1.0f, 0.3f, 0.6f);
			e.setKillByHeadbutt();
			Destination.addDestination(1200, 310, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
		}
		// demo #28: Reproduce enemies
		else if (whichLevel == 28) {
			Level.reset(460, 320, 10, 0, true, 0, 0);
			PopUpScene.printTimedMessage("Shoot the enemies\nbefore they reproduce", 1);
			// set up our bullets
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(20, 290, 30, 30, "greenball.png", 1, 0, 0.6f);
			h.makeTouchShoot();
			Bullet.configBullets(100, 10, 10, "greyball.png", 0, -10, 20, -5);
			Bullet.setHitSound("badsound.ogg");
			Enemy e = Enemy.addStationaryEnemy(230, 20, 10, 10, "redball.png", 1.0f, 0.3f, 0.6f);
			e.setReproductions(2, 2, 2);
			Level.setVictoryEnemyCount();
		}
		// demo #29: Reproduce enemies with gravity
		else if (whichLevel == 29) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("These enemies are\nreally tricky", 1);
			// set up our bullets
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 290, 30, 30, "greenball.png", 1, 0, 0.6f);
			Enemy e = Enemy.addMoveableEnemy(230, 20, 10, 10, "redball.png", 1.0f, 0.3f, 0.6f);
			e.setMoveByTilting();
			e.setReproductions(2, 2, 2);
			Destination.addDestination(290, 290, 10, 10, "mustardball.png", 2, 0);
			Level.setVictoryDestination(1);
		}
		// demo #30: Triggers
		else if (whichLevel == 30) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Reach the purple ball\nto reveal the\nnext step", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 290, 30, 30, "greenball.png", 1, 0, 0.6f);
			Obstacle o = Obstacle.addCircularObstacle(300, 5, 10, 10, "purpleball.png", null, 0, 1, 0, 1);
			o.setTrigger(0, 0);
			Level.setVictoryDestination(1);
			Controls.addGoodieCount(0);
		}
		// demo #31: SVG
		else if (whichLevel == 31) {
			Level.reset(3 * 460, 320, 10, 0, true, 0, 10);
			PopUpScene.printTimedMessage("Obstacles can\nbe drawn from SVG\nfiles", 1);
			Obstacle.drawBoundingBox(0, 0, 3 * 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			Hero.setJumpImpulses(0, -10);
			h.makeTouchJumpable();
			Obstacle.loadSVG("shape.svg", 1, 0, 0, 1, 0, 0, 2f, 0.5f, 241f, 300f);
			Destination.addDestination(1200, 10, 10, 10, "mustardball.png", 2, 0);
			Controls.addZoomInButton(0, 0, 20, 20, "red.png", 4);
			Controls.addZoomOutButton(440, 0, 20, 20, "red.png", 0.25f);
			Level.setVictoryDestination(1);
		}
		// demo #32: victory by goodies
		else if (whichLevel == 32) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Collect all\nblue balls\nto win", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(20, 20, 30, 30, "greenball.png", 1, 0, 0.6f);
			//			for (int i = 0; i < 5; ++i)
			//				Goodie.addStationaryGoodie(50 * i + 5, 10 * i + 5, 10, 10, "blueball.png");
			//			Level.setVictoryGoodies(5);
			Controls.addGoodieCount(5);
		}
		// demo #33: simple animation
		else if (whichLevel == 33) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printTimedMessage("Nudge, Nudge, Wink Wink!", 1);
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero h = Hero.addHero(40, 70, 30, 30, "winkie.png", 1, 0, 0.6f);
			long plan[] = { 800, 100 };
			h.animate(plan, true);
			Destination.addDestination(290, 60, 10, 10, "mustardball.png", 1, 0);
			Level.setVictoryDestination(1);
		}
		// demo #34: this is really cruel. Some Eng98 students thought up this
		// level. Paths allow enemies to defy physics. You need to understand
		// what happens during printMessageAndWait in order to beat this level
		else if (whichLevel == 34) {
			Level.reset(460, 320, 10, 10, true, 0, 0);
			PopUpScene.printMessageAndWait("Reach the destination\nto win the game.\n\n(tap to start)");
			Obstacle.drawBoundingBox(0, 0, 460, 320, "red.png", 1, .3f, 1);
			Hero.addHero(215, 290, 30, 30, "greenball.png", 1, 0, 0.6f);
			Destination.addDestination(215, 10, 20, 20, "mustardball.png", 1, 0);
			Enemy e = Enemy.addMoveableEnemy(10, -200, 440, 440, "redball.png", 0, 0, 0);
			e.setKillText("Ha Ha Ha");
			e.applyPath(new Path(3).to(10, -900).to(10, 260).to(10, -200), 3);
			Level.setVictoryDestination(1);
		}
	}

	/**
	 * If a game uses Obstacles that are triggers, it must provide this to
	 * specify what to do when such an obstacle is hit by a hero
	 */
	public void onTrigger(int score, int id)
	{
		if (id < 5) {
			PopUpScene.printTimedMessage("Collect blue balls\nto activate the next\npurple ball", 1);
			//Goodie.addStationaryGoodie(10, 10, 10, 10, "blueball.png");
			Obstacle o = Obstacle.addCircularObstacle(300, 55 + 50 * id, 10, 10, "purpleball.png", null, 0, 1, 0, 1);
			o.setTrigger(id + 1, id + 1);
		}
		else {
			PopUpScene.printTimedMessage("The destination is\nnow available", 1);
			Destination.addDestination(200, 200, 20, 20, "mustardball.png", 1, 0);
		}
	}

	/**
	 * Draw help scenes
	 * 
	 * A real game would need to provide much better help
	 */
	public void configureHelpScene(int whichScene)
	{
		if (whichScene == 1) {
			HelpScene.reset(0, 0, 0);
			HelpScene.addText(100, 5, "The levels of this game demonstrate\nthe features of the GameFramework");

			HelpScene.addDecoration(50, 60, 30, 30, "greenball.png");
			HelpScene.addText(100, 60, "This is a hero");

			HelpScene.addDecoration(50, 100, 30, 30, "blueball.png");
			HelpScene.addText(100, 100, "This is an object you can collect");

			HelpScene.addDecoration(50, 140, 30, 30, "redball.png");
			HelpScene.addText(100, 140, "This is an enemy.  Beware!");

			HelpScene.addDecoration(50, 180, 30, 30, "mustardball.png");
			HelpScene.addText(100, 180, "This is a destination that the\nhero(s) must reach");

			HelpScene.addDecoration(50, 220, 30, 30, "purpleball.png");
			HelpScene.addText(100, 220, "This is an obstacle you can collide with");

			HelpScene.addDecoration(50, 260, 30, 30, "greyball.png");
			HelpScene.addText(100, 260, "This is a bullet");
		}
		else if (whichScene == 2) {
			HelpScene.reset(1, 1, 0);
			HelpScene.addText(100, 5, "See the SampleActivity.java file\nfor more details");
		}
	}

}